* open the file
use "for_ITSA_data.DTA"

* dataframe convert to time series
tsset week

* descriptive analysis
sum

*Create a rate trend line by sentiment
line positive_score negative_score week, legend(size(medsmall)) tline(12 35, lc(gray))

*add tline options
line positive_score negative_score week, graphregion(fcolor(white)) legend(size(medsmall)) tline(12 35, lp(dash) lc(gray) lw(0.5)) tline(3 13 43, lc(red) lw(0.15)) tline(9 28, lc(blue) lw(0.15))


***Interrupted time series with Prais-Winston**

* negative ratio
itsa neg_ratio, trperiod(11; 35) replace posttrend prais rhotype(tscorr) vce(robust) fig

* positive ratio
itsa pos_ratio, trperiod(11; 35) replace posttrend prais rhotype(tscorr) vce(robust) fig


* overall tone intensity
itsa total_mean, trperiod(11; 35) replace posttrend prais rhotype(tscorr) vce(robust) fig

* negative tone intensity
itsa neg_mean, trperiod(11; 35) replace posttrend prais rhotype(tscorr) vce(robust) fig

* positive tone intensity
itsa pos_mean, trperiod(11; 35) replace posttrend prais rhotype(tscorr) vce(robust) fig


* end
